//城市选择
var app = getApp();
Page({
  data: {
    code:0,
    sex: ['男', '女'],
    index: 0,
    date: '2016-09-01',
    zj: ['身份证', '护照','港澳通行证','台湾证','军官证','回乡证','台胞证','出生证','户口本','其他证件'],
    indexzj: 0,
  },
  bindPickerChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      index: e.detail.value
    })
  },
  bindPickerChangezj: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      indexzj: e.detail.value
    });
    wx.navigateTo({
     url: '../certificates/index'+'?zjid='+e.detail.value
   })
  },
  switchChange: function (e) {
    console.log('switch1 发生 change 事件，携带值为', e.detail.value);
  },
   bindDateChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      date: e.detail.value
    })
  },
  formSubmit: function (e) {
    var adds = e.detail.value;
    var cartId = this.data.cartId;
    wx.request({
      url: app.d.ceshiUrl + '/Api/Address/add_adds',
      data: {
        user_id:app.d.userId,
        code: this.data.code,
      },
      method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      header: {// 设置请求的 header
        'Content-Type':  'application/x-www-form-urlencoded'
      },
      success: function (res) {
        // success
        var status = res.data.status;
        if(status==1){
          wx.showToast({
            title: '保存成功！',
            duration: 2000
          });
        }else{
          wx.showToast({
            title: res.data.err,
            duration: 2000
          });
        }
        wx.redirectTo({
          url: 'user-address/user-address?cartId=' + cartId
        });
      },
      fail: function () {
        // fail
        wx.showToast({
          title: '网络异常！',
          duration: 2000
        });
      }
    })


  },
  onLoad: function (options) {
    // 生命周期函数--监听页面加载
    var that = this;
    

  },

})